![]() 11/18/2014 at 14:27 • Filed to: Programming | ![]() | ![]() |
this is the !!!error: Indecipherable SUB-paragraph formatting!!! i'm working on right now. I'm so lost trying to count the bastards.
Help. Take this GT350 for help.
[update]: NOW SHUFFEL THE THIGNS!
![]() 11/18/2014 at 14:30 |
|
!!! UNKNOWN CONTENT TYPE !!!
![]() 11/18/2014 at 14:36 |
|
I'm in an introductory Computer Science class myself and I have no clue what the heck that lab is about. Now I'm scared...
!!! UNKNOWN CONTENT TYPE !!!
![]() 11/18/2014 at 14:41 |
|
I've got the skills to figure this out but I don't have the will or time.
![]() 11/18/2014 at 14:42 |
|
I've been out of school too long.
![]() 11/18/2014 at 14:43 |
|
I can no essplain...
![]() 11/18/2014 at 14:43 |
|
just make and array of size 10 "counts(10)" then iterate through and increment the corresponding spot in the array for each number you see.
x = next nubmer in the given numbers
counts(x)++
move to next number
what language is this?
*edit* I've never used python, so my pseudocode is probably shit, but I hope you get the idea.
![]() 11/18/2014 at 14:44 |
|
Python
![]() 11/18/2014 at 14:44 |
|
There was a time when I knew how to do this. Then I finished my AP computer science course, and decided that I never wanted to code again. It's been a happy 8 years.
![]() 11/18/2014 at 14:47 |
|
never used it, but I have a raspberry pi at home that is telling me I need to learn.
![]() 11/18/2014 at 14:48 |
|
do you get what I am saying though, as far as how to do it? or is it a more specific thing that you aren't getting?
![]() 11/18/2014 at 14:49 |
|
Set up your counts list, then go in a loop (yeah, I know, inefficient, but ends/means, right?) of 1000 iterations, in each iteration make the call random.randint(0,9) and truncate it (so you get perfect 0,1,...,9. Use the number as the key in to your counts, using a ++ to increment the count up one from what it was.
![]() 11/18/2014 at 14:49 |
|
I got it now but the way you tried to explain was way off
![]() 11/18/2014 at 14:53 |
|
Good to know. The method, or the syntax? I should have probably not skimmed it, but I am at work.
![]() 11/18/2014 at 15:25 |
|
Here, test run in PyCharm CE, 2.7.whatever
import random
counts=[0,0,0,0,0,0,0,0,0,0]
for i in range(1000):
var = random.randint(0,9)
counts[var] += 1
print counts
![]() 11/18/2014 at 15:59 |
|
Here it is with a shuffle-not-using-shuffle (list.pop is the trick):
import random
def CM1Shuffle(arg1):
RetVal = [0] * len(arg1)
for i in range(len(arg1)):
iPull = random.randint(0,len(arg1)-1)
RetVal[i] = arg1.pop(iPull)
return RetVal
counts=[0,0,0,0,0,0,0,0,0,0]
for i in range(1000):
var = random.randint(0,9)
counts[var] += 1
print 'Counts'
print counts
sCounts = CM1Shuffle(counts)
print 'sCounts'
print sCounts